package com.xidian.zhiancloud.service.riskcontrol.risksystem;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.xidian.zhiancloud.dao.riskcontrol.risksystem.TRiskPointTypeStatusMapper;
import com.xidian.zhiancloud.model.riskcontrol.TControlLevelStatusList;
import com.xidian.zhiancloud.model.riskcontrol.TRiskPointTypeStatusList;
import com.xidian.zhiancloud.model.riskcontrol.entity.TPointTypeStaEntity;
import com.xidian.zhiancloud.qo.BaseReqQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.ArrayList;
import java.util.List;

/**
 * 风险管控-系统设置-风险点类型设置
 */
@Service
public class TRiskPointTypeStatusService extends ServiceImpl
        <TRiskPointTypeStatusMapper, TRiskPointTypeStatusList> {

    @Autowired
    TRiskPointTypeStatusMapper tRiskPointTypeStatusMapper;

    public Page<TRiskPointTypeStatusList> getTRiskPointTypeStatusList(
           BaseReqQuery reqdata,Long companyId,String riskcontrolId){
        PageHelper.startPage(reqdata.getPageNum(), reqdata.getPageSize());
        Page<TRiskPointTypeStatusList> pagedata =tRiskPointTypeStatusMapper
                .getTRiskPointTypeStatusList(reqdata.getSearchKey(),companyId,riskcontrolId);
        return pagedata;
    }

    public int addTRiskPointTypeStatus(TRiskPointTypeStatusList tRPointTypeSta){
        return tRiskPointTypeStatusMapper.addTRiskPointTypeStatus
                (tRPointTypeSta);
    }

    public int updateTRiskPointTypeStatus(String id,TRiskPointTypeStatusList tRPointTypeSta){
        return tRiskPointTypeStatusMapper.updateTRiskPointTypeStatus(id,tRPointTypeSta);
    }

    public int deleteTRiskPointTypeStatus(String id){
        List<String> list = getList(id);
        return tRiskPointTypeStatusMapper.deleteTRiskPointTypeStatus(list);
    }

    /**
     * id放入list
     * @param id id(多个已逗号分隔)
     * @return List集合
     */
    public List<String> getList(String id) {
        List<String> list = new ArrayList<String>();
        String[] str = id.split(",");
        for (int i = 0; i < str.length; i++) {
            list.add(str[i]);
        }
        return list;
    }

    public Page<TRiskPointTypeStatusList> getExportTPointTypeStaData
           (Long companyId,String riskcontrolId){
        return tRiskPointTypeStatusMapper.getExportTPointTypeStaData
                (companyId,riskcontrolId);
    }

    public int addTPointTypeStaSS00Entity
            (Long companyId,Long userId,TPointTypeStaEntity pointTyStaEnt){
        return tRiskPointTypeStatusMapper.addTPointTypeStaSS00Entity
                (companyId,String.valueOf(userId),pointTyStaEnt);
    }

    public int addTPointTypeStaZY00Entity
            (Long companyId,Long userId,TPointTypeStaEntity pointTyStaEnt){
        return tRiskPointTypeStatusMapper.addTPointTypeStaZY00Entity
                (companyId,String.valueOf(userId),pointTyStaEnt);
    }

    public int addTPointTypeStaGY00Entity
            (Long companyId,Long userId,TPointTypeStaEntity pointTyStaEnt){
        return tRiskPointTypeStatusMapper.addTPointTypeStaGY00Entity
                (companyId,String.valueOf(userId),pointTyStaEnt);
    }

}
